package me.bulb.conditional;

import java.util.Collection;

/**
 * @author lijinting01
 *
 */
public class CollectionConditional extends ValueConditional<Collection<?>, me.bulb.conditional.CollectionConditional> {

	/**
	 * @param value
	 */
	private CollectionConditional(Collection<?> value) {
		super(value);
	}

	/**
	 * with the value to be tested.
	 * 
	 * @param e
	 *            the value to be tested. if null is provided as argument, a
	 *            CollectionConditional with empty collection is returned.
	 * @return
	 */
	public static final CollectionConditional with(Collection<?> e) {
		return new CollectionConditional(e);
	}

	/**
	 * 判断集合是否为空
	 * 
	 * @return
	 */
	public CollectionConditional onEmpty() {
		return addCondition(new CollectionEmptyCondition());
	}

	/**
	 * 判断集合是否非空
	 * 
	 * @return
	 */
	public CollectionConditional onNotEmpty() {
		return addCondition(new CollectionNotEmptyCondition());
	}

	/**
	 * 集合包含某个元素
	 * 
	 * @param element
	 *            即将用于检测的元素
	 * @return
	 */
	public CollectionConditional onContains(Object element) {
		return addCondition(new CollectionContainsCondition(element));
	}

	/**
	 * 集合不包含某个元素
	 * 
	 * @param element
	 *            即将用于检测的元素
	 * @return
	 */
	public CollectionConditional onNotContains(Object element) {
		return addCondition(new CollectionNotContainsCondition(element));
	}

}
